package com.insight.common.exception;

/**
 * T022: 资源未找到异常
 * 当请求的资源（数据源、表、任务等）不存在时抛出
 */
public class ResourceNotFoundException extends RuntimeException {

    /**
     * 资源类型
     */
    private final String resourceType;

    /**
     * 资源标识
     */
    private final Object resourceId;

    public ResourceNotFoundException(String resourceType, Object resourceId) {
        super(String.format("%s with ID '%s' not found", resourceType, resourceId));
        this.resourceType = resourceType;
        this.resourceId = resourceId;
    }

    public ResourceNotFoundException(String message) {
        super(message);
        this.resourceType = null;
        this.resourceId = null;
    }

    public ResourceNotFoundException(String resourceType, Object resourceId, Throwable cause) {
        super(String.format("%s with ID '%s' not found", resourceType, resourceId), cause);
        this.resourceType = resourceType;
        this.resourceId = resourceId;
    }

    public String getResourceType() {
        return resourceType;
    }

    public Object getResourceId() {
        return resourceId;
    }
}
